package admin

import (
	"context"
	"server/internal/model"
	"server/internal/service"

	"server/api/admin/system"
)

func (c *ControllerSystem) PermissionUpdate(ctx context.Context, req *system.PermissionUpdateReq) (res *system.PermissionUpdateRes, err error) {
	res = new(system.PermissionUpdateRes)
	err = service.SystemPermission().UpdateById(ctx, req.Id, model.SystemPermissionUpdateInput{
		Type:     req.Type,
		ParentId: req.ParentId,
		Name:     req.Name,
		Code:     req.Code,
		Routes:   req.Routes,
		Sort:     req.Sort,
		Memo:     req.Memo,
	})
	return res, err
}
